//http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/ tested add function
function addElement() {

  var ni = document.getElementById('myDiv');

  var numi = document.getElementById('theValue');

  var num = (document.getElementById('theValue').value -1)+ 2;

  numi.value = num;

  var newdiv = document.createElement('div');

  var divIdName = 'my'+num+'Div';

  newdiv.setAttribute('id',divIdName);

  newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>';

  ni.appendChild(newdiv);

}

function removeElement(divNum) {

  var d = document.getElementById('myDiv');

  var olddiv = document.getElementById(divNum);

  d.removeChild(olddiv);

}

//da tested ok
var checkbox = document.createElement('input');
		checkbox.type = "checkbox";
		checkbox.name = "name";
		checkbox.value = "value";
		checkbox.id = "id";
    checkbox.checked=true;

		var label = document.createElement('label');
		label.htmlFor = "id";
		label.appendChild(document.createTextNode('label'));

		var container = window.opener.document.getElementById("cb_area");
		container.appendChild(checkbox);
		container.appendChild(label);
